<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
    <!--顶部导航栏-->
    <ul th:fragment="top-menu" id="apptop" class="layui-nav" lay-filter="" style="text-align: center;margin-bottom: 0;">
        <li class="layui-nav-item"><a href="/home/index">首页</a></li>
        <li class="layui-nav-item"><a href="/home/news/homeListPage">全部新闻</a></li>
<!--        <li class="layui-nav-item"><a href="/home/news/homeListPicPage">新闻图示</a></li>-->
        <li class="layui-nav-item"><a href="/home/news/featureListPage?categoryId=1">系统特色</a></li>
        <li class="layui-nav-item"><a href="/home/news/recommendListPage">猜你喜欢</a></li>

        <div style="float: right;">
        <li class="layui-nav-item" th:if="${session.user} == null">
            <a href="/home/login">登录</a>
        </li>
<!--        <li class="layui-nav-item" th:if="${session.user} == null">-->
<!--            <a th:href="@{/register}">注册</a>-->
<!--        </li>-->
        <li class="layui-nav-item" th:if="${session.user} != null">
            <a th:href="'/home/user/homeDetail?id='+${session.user.id}">
                <img th:src="@{${session.user.field1}==null? '/static/home/images/user-head/1.jpg':${'/file/fileDown?saveName='+session.user.field1}}"
                    class="layui-nav-img" th:text="${session.user.name}"></a>
            <dl class="layui-nav-child">
                <dd><a th:href="'/home/user/homeDetail?id='+${session.user.id}">个人中心</a></dd>
                <dd><a th:href="'/home/news/mypublishPage?userId='+${session.user.id}">我的发布</a></dd>
                <dd><a th:href="'/home/news/attentionListPage?userId='+${session.user.id}">我的关注</a></dd>
                <dd><a href="javascript:void(0);" id="JsSignOut">退出登录</a></dd>
                <dd th:if="${session.user.type==0}"><a th:href="@{/user/index}">后台管理</a></dd>
            </dl>
        </li>
        </div>
        <script src="/static/common/plugs/vue/vue.js"></script>
        <script src="/static/common/plugs/jquery/jquery-3.3.1.min.js"></script>
        <script th:inline="javascript">
            //安全退出
            $('#JsSignOut').click(function(){
                layer.confirm('确要定退出登录吗？', {
                    title:'系统提示',
                    btn: ['确定','取消']
                }, function(){
                    $.post("/home/logOut",function (res) {
                        console.log(res);
                        if (res.success) {
                            layer.msg(res.msg, {icon: 1, time: 1500});
                            setTimeout(location.reload(), 1500);
                            return;
                        }
                        layer.msg(res.msg, {icon: 2, time: 1500});
                    })
                });
            });

            /*页面跳转*/
            function goTo(url) {
                window.location.href=url;//刷新当前界面
            }
        </script>
    </ul>
</html>
